<?php

error_reporting(E_ALL);

/**
 * ECommerce - class.Usuario.php
 *
 * $Id$
 *
 * This file is part of ECommerce.
 *
 * Automatically generated on 17.11.2011, 16:09:48 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/* user defined includes */
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001379-includes begin
require_once('class.ModeloUsuario.php');
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001379-includes end

/* user defined constants */
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001379-constants begin
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001379-constants end

/**
 * Short description of class Usuario
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class Usuario
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    /**
     * Short description of attribute row
     *
     * @access public
     * @var Array
     */
    public $row = null;

    /**
     * Short description of attribute ModeloUsuario
     *
     * @access public
     * @var string
     */
    public $ModeloUsuario = '';

    // --- OPERATIONS ---

    /**
     * Short description of method isAdmin
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function isAdmin()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001382 begin
        if (@$_SESSION["userRow"]["Rol"] == "Administrador") { 
        	return true;
        }
        else {
        	return false;
        }  
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001382 end
    }

    /**
     * Short description of method login
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  user
     * @param  pass
     * @return void
     */
    public function login($user, $pass)
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001384 begin
        if (!@$_SESSION['userRow']) {
            $_SESSION["userRow"] = "";
            $_SESSION["venta"]=array();
           // session_unset();     
            //@session_destroy();
    		$this->row = $this->ModeloUsuario->getRowsByUserPassword($user,$pass); 
	    	$_SESSION['userRow'] = $this->row;	   	
        }
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001384 end
    }

    /**
     * Short description of method logout
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function logout()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001388 begin
        $_SESSION["userRow"] = "";
        session_unset();     
        @session_destroy();
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001388 end
    }

    /**
     * Short description of method Usuario
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function Usuario()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000138A begin
        $this->ModeloUsuario = new ModeloUsuario();
       // session_start();
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000138A end
    }

    /**
     * Short description of method isLogged
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function isLogged()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000138C begin
        if (@$_SESSION["userRow"] == null)
        	return false;
        else
        	return true;
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000138C end
    }

    /**
     * Short description of method isRegistred
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function isRegistred()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000138E begin
        if (@$_SESSION["userRow"]["Rol"] == "Usuario") { 
        	return true;
        }
        else {
        	return false;
        }  
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000138E end
    }

    /**
     * Short description of method checkUsuario
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function checkUsuario()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001390 begin
        if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 900)) {	
		session_destroy();   // destroy session data in storage
		session_unset();     // unset $_SESSION variable for the runtime
		header ("Location:index.php");
		}
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001390 end
    }

} /* end of class Usuario */

?>